<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 쿼리 관련 로그
 */
class LogSql
{
	/**
	* 실행한 쿼리 내용을 찍어준다.
	*
	* We use this as a simple mechanism to access the logging
	* class and send messages to be logged.
	*
	* @access	public
	* @param    log_level
	* @return	void
	*/
	function log_sql($log_level = 'debug') {
		
		$CI =& get_instance();		

		if ($log_level == 'error') {
			log_message('error','##########################################################');
			log_message('error','## 아래 실행 쿼리 에러');
			log_message('error','##########################################################');
			log_message('error','## SQL : '.$CI->db->last_query());
			log_message('error','##########################################################');
			$CI->db->_error_number();
			$CI->db->_error_message();
		} else {
			log_message($log_level,'## SQL : '.$CI->db->last_query());
		}
	}
	
	/**
	* 실행한 쿼리 결과를 찍어준다.
	*
	* We use this as a simple mechanism to access the logging
	* class and send messages to be logged.
	*
	* @access	public
	* @param    result 결과배열
	* @param    log_level
	* @return	void
	*/
	function log_result($result, $log_level = 'debug') {

		$CI =& get_instance();		
		log_message($log_level, "## RESULT=".print_r($result, TRUE));
	}

	/**
	* 배열 내용을 쓴다.
	*
	* We use this as a simple mechanism to access the logging
	* class and send messages to be logged.
	*
	* @access	public
	* @param    result 결과배열
	* @param    log_level
	* @return	void
	*/
	function log_result_with_title($title, $result, $log_level = 'debug') {

		$CI =& get_instance();		
		log_message($log_level, "## $title=".print_r($result, TRUE));
	}

}

/* End of file LogSql.php */
/* Location: ./application/libraries/LogSql.php */